package com.jason.canvas.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.View;

/**
 * @DESC:
 * @Author: Jason
 * @Date: 16/9/20
 * @Time: 22:42
 */

public class PathAddView11 extends View {

    private Path mPath; // 路径对象
    private Paint mPaint; // 路径画笔对象
    private TextPaint mTextPaint; // 文本画笔对象


    public PathAddView11(Context context, AttributeSet attrs) {
        super(context, attrs);

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setColor(Color.CYAN);
        mPaint.setStrokeWidth(5);


        mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG | Paint.LINEAR_TEXT_FLAG);
        mTextPaint.setColor(Color.DKGRAY);
        mTextPaint.setTextSize(20);


        // 实例化路径
        mPath = new Path();

        // 添加一条弧线到Path中
        RectF oval = new RectF(100, 100, 300, 400);
        mPath.addOval(oval, Path.Direction.CW);

    }

    @Override
    protected void onDraw(Canvas canvas) {
        // 绘制路径
        canvas.drawPath(mPath, mPaint);

        // 绘制路径上的文字
        canvas.drawTextOnPath("ad收到货卡就是佛我诶人是开放和可使肌肤很深刻的金凤凰", mPath, 0, 0, mTextPaint);
    }
}
